<? require "../../../global.php";?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
require_once('chinabank.MotoClient.php');

// 消费
$motoClient = new MotoClient();

$cardid     =trim($_POST["cardid"]);       // 信用卡卡号
$month     =trim($_POST["month"]);       // 月
$year     =trim($_POST["year"]);       // 年
$year_month = $year.$month;
$cvv     =trim($_POST["cvv"]);       // 年
$money     =trim($_POST["money"]);       // 金额 单位元
$name     =trim($_POST["name"]);       // 持卡人姓名
$idcard     =trim($_POST["idcard"]);       // 证件号
$type1    =trim($_POST["type1"]);	//支付款项类型	
 $orderid=trim($_POST[ "orderid" ]);
if($idcard=="")
{
	$idcard="999999";
}
$result = $motoClient->consume( $_POST[ "orderid" ], $cardid, $year_month, $money*100, array("name"=>$name, "idcard"=>$idcard, "cvv2"=>$cvv, 'mobile'=>'139','type1'=>$type1, 'note'=>'nothing'));

//echo $result[$motoClient->MOTO_SEARCH_AMOUNT] . "<br />";
//print_a("RESULT Array", $result);
//echo "oid: {$result[$motoClient->MOTO_KEY_OID]},<br/> authcode: {$result[$motoClient->MOTO_KEY_AUTHID]},<br/>";
echo "result: {$result[result]}<br/>";

if($result[result]==0 and !strstr($result[result],"E"))//当返回0时表示支付成功
{
	//更改数据库里的订单状态
			require RootDir."/inc/dabase_mysql.php";
			$mydb=new YYBDB();
			if(strstr($type1,"dj"))
			{
				$sql2=",earnestmoney=".$money.",paytimeearnestmoney=".time().",";
				$paytype="dj";
			}
			else
			{
				$sql2=",balance=".$money.",paytimebalance=".time().",";
				$paytype="wk";
			}

			$sql="update ".$SystemConest[7]."orderpaylist set paytype='信用卡'
			".$sql2."
			earnbizhong='RMB',isconfim=1  where orderno='".$orderid."'";
			 $mydb->db_query($sql);

			 $rs=$mydb->db_query("select * from ".$SystemConest[7]."tourorder where orderno='".$orderid."'");
			 //支付成功，执行发送邮件操作
			 echo "<iframe  src='/dszSendMail_sendMailInfo_type_paysuss_orderno_".$orderid."_paytype_".$paytype."_email_".$rs["nuseremail"]."' 
frameborder=0 scrolling=no width=1 height=1></iframe>";
			 unset($rs);
			 
			 

}
elseif($result[result]==1)
{
	echo "<br>您的卡是非实时交易卡，请稍后请进入<a href='http://www.dreams-travel.com/pay/order/find_order.asp'>订单查询页面查询</a><br>";
}
else
{
	//支付失败时
	echo "你的信用卡不能在本系统支付,或者你的信用卡设置了密码,或者卡号不对,所以不能支付!<br>请换一张信用卡或者换一种支付方式!";
}


?>
